extern crate clap;
extern crate core;
extern crate gl;
extern crate sdl2;

use crate::player::Player;
extern crate cgmath;

mod gl_renderer;
mod mqueue;
mod player;
mod video;


//#[feature(mutex_unlock)]
fn main() -> Result<(), String> {
    // 相对于当前文件找到YAML文件，类似于找到模块的方式
    let yaml = clap::load_yaml!("cli.yml");
    let matches = clap::App::from_yaml(yaml).get_matches();
    println!("{:?}", matches);

    let mut path = matches.value_of("INPUT").unwrap();
    let mut output = matches.value_of("OUTPUT").unwrap();
    let mut position_x = matches
        .value_of("POSITION_X")
        .unwrap()
        .parse::<i32>()
        .unwrap();
    let mut position_y = matches
        .value_of("POSITION_Y")
        .unwrap()
        .parse::<i32>()
        .unwrap();
    let mut width = matches.value_of("WIDTH").unwrap().parse::<i32>().unwrap();
    let mut height = matches.value_of("HEIGHT").unwrap().parse::<i32>().unwrap();
    let mut nvidia_decoder = matches
        .value_of("NVIDIA_DECODER")
        .unwrap()
        .parse::<bool>()
        .unwrap();

    unsafe {
        let mut player = Player::new(path, position_x, position_y, width, height, nvidia_decoder);
        player.player();
    }

    Ok(())
}
